<!-- 月度点评 -->

<template>
  <div class="evaluation_month_container">
    <template>
      <el-tabs v-model="activeName" type="card" @tab-click="handleClick">
        
        <!-- 班级满意度 -->
        <el-tab-pane label="班级满意度" name="class">
          <div class="search_box">
            <div @click="exportClass" class="btn btn_add">
              <i class="el-icon-plus"></i>
              <span class="btn_txt">导出</span>
            </div>

            <div class="btn btn_search fr" @click="searchClassData(searchFormClass)">
              <span class="btn_txt">查询</span>
            </div>

            <div class="fr">
              <el-form :model="searchFormClass" :inline="true" class="searchFormClass">
                <el-form-item size="small">
                  <el-select  style="width:200px;" multiple collapse-tags v-model="searchFormClass.schoolId" placeholder="选择校区(多选)">
                    <el-option v-for="(item,key) in schoolList" :key="key" :label="item.schoolName" :value="item.schoolId">
                    </el-option>
                  </el-select>
                </el-form-item>
                <el-form-item size="small">
                  <el-date-picker
                    style="width:125px;"
                    value-format="yyyy-MM"
                    v-model="searchFormClass.financialMonth"
                    type="month"
                    placeholder="选择月">
                  </el-date-picker>
                </el-form-item>
              </el-form>
            </div>
            
            <div class="clear"></div>
          </div>

          <div class="table_box">
            <adminTable :tableHead="tableHeadClass" :tableData="tableDataClass"></adminTable>
            <el-pagination
              class="pagination"
              @size-change="handleSizeChange"
              @current-change="handleCurrentChange"
              :current-page="pageClass.curPage"
              :page-sizes="[10, 20, 50]"
              :page-size="pageClass.pageSize"
              layout="total, sizes, prev, pager, next, jumper"
              :total="pageClass.totalRows">
            </el-pagination>
          </div>
        </el-tab-pane>
        <!-- 班级满意度 end -->

        <!-- 教学满意度 -->
        <el-tab-pane label="教学满意度" name="teach">
          <div class="search_box">
            <div @click="exportTeach" class="btn btn_add" >
              <i class="el-icon-plus"></i>
              <span class="btn_txt">导出</span>
            </div>

            <div class="btn btn_search fr" @click="searchTeachData(searchFormTeach)">
              <span class="btn_txt">查询</span>
            </div>

            <div class="fr">
              <el-form :model="searchFormTeach" :inline="true" class="searchFormTeach">
                <!-- <el-form-item size="small">
                  <el-select clearable style="width:150px;" multiple collapse-tags v-model="searchFormTeach.schoolId" placeholder="选择校区(多选)">
                    <el-option v-for="(item,key) in schoolList" :key="key" :label="item.schoolName" :value="item.schoolId">
                    </el-option>
                  </el-select>
                </el-form-item> -->

                <el-form-item size="small">
                  <el-date-picker
                    style="width:125px;"
                    value-format="yyyy-MM"
                    v-model="searchFormTeach.financialMonth"
                    type="month"
                    placeholder="选择月">
                  </el-date-picker>
                </el-form-item>
                
              </el-form>
            </div>

            <div>
              <!-- <el-form-item size="small">
                <el-select clearable style="width:150px;" multiple collapse-tags v-model="searchFormTeach.schoolId" placeholder="选择校区(多选)">
                  <el-option v-for="(item,key) in schoolList" :key="key" :label="item.schoolName" :value="item.schoolId">
                  </el-option>
                </el-select>
              </el-form-item> -->
            </div>
            
            <div class="clear"></div>
          </div>

          <div class="select_box">
            <template>
              <el-radio v-model="radio" label="1">班级分析</el-radio>
              <el-radio v-model="radio" label="2">老师对比</el-radio>
            </template>

            <el-select @change="changeSchool" v-if="radio == 1" multiple collapse-tags clearable style="width:200px;" size="mini" v-model="searchFormTeach.schoolId" placeholder="请选择校区">
              <el-option v-for="(item,key) in schoolList" :key="key" :label="item.schoolName" :value="item.schoolId">
              </el-option>
            </el-select>

            <el-select @change="changeSubject" v-if="radio == 2" clearable style="width:120px;" size="mini" v-model="searchFormTeach.subject" placeholder="请选择科目">
              <el-option v-for="(item,key) in subjectList" :key="key" :label="item.subjectName" :value="item.subjectId">
              </el-option>
            </el-select>


          </div>

          

          <div class="table_box year_box">
            
            <adminTable v-if="radio == 1" :tableHead="tableHeadTeachClass" :tableData="tableDataTeachClass"></adminTable>
            <adminTable v-if="radio == 2" :tableHead="tableHeadTeachTeacher" :tableData="tableDataTeachTeacher"></adminTable>
            <el-pagination
              class="pagination"
              @size-change="handleSizeChangeYear"
              @current-change="handleCurrentChangeYear"
              :current-page="pageTeach.curPage"
              :page-sizes="[10, 20, 50]"
              :page-size="pageTeach.pageSize"
              layout="total, sizes, prev, pager, next, jumper"
              :total="pageTeach.totalRows">
            </el-pagination>
          </div>
        </el-tab-pane>
        <!-- 教学满意度 end-->

    
        <!-- 校区满意度 -->
        <el-tab-pane label="校区满意度" name="school">
          <div class="search_box">
            <div  @click="exportSchool" class="btn btn_add">
              <i class="el-icon-plus"></i>
              <span class="btn_txt">导出</span>
            </div>

            <div class="btn btn_search fr" @click="searchSchoolData(searchFormSchool)">
              <span class="btn_txt">查询</span>
            </div>

            <div class="fr">
              <el-form :model="searchFormSchool" :inline="true" class="searchFormSchool">
                <el-form-item size="small">
                  <el-select  clearable style="width:200px;" multiple collapse-tags v-model="searchFormSchool.schoolId" placeholder="选择校区(多选)">
                    <el-option v-for="(item,key) in schoolList" :key="key" :label="item.schoolName" :value="item.schoolId">
                    </el-option>
                  </el-select>
                </el-form-item> 

                <el-form-item size="small">
                  <el-date-picker
                    style="width:125px;"
                    value-format="yyyy-MM"
                    v-model="searchFormSchool.financialMonth"
                    type="month"
                    placeholder="选择月">
                  </el-date-picker>
                </el-form-item>

                
              </el-form>
            </div>
            
            <div class="clear"></div>
          </div>

          <div class="table_box month_box">
            <adminTable :tableHead="tableHeadSchool" :tableData="tableDataSchool" ></adminTable>
            <el-pagination
              class="pagination"
              @size-change="handleSizeChangeMonth"
              @current-change="handleCurrentChangeMonth"
              :current-page="pageSchool.curPage"
              :page-sizes="[5, 20, 50]"
              :page-size="pageSchool.pageSize"
              layout="total, sizes, prev, pager, next, jumper"
              :total="pageSchool.totalRows">
            </el-pagination>
          </div>
        </el-tab-pane>
        <!-- 校区满意度 end-->

        <!-- 逐题分析 -->
        <el-tab-pane label="逐题分析" name="qsAnalysis">
          <question-analysis :questionType="'midTerm'" :isActiveEcharts="isActiveEcharts"></question-analysis>
        </el-tab-pane>
        <!-- 逐题分析 end-->

      </el-tabs>
    </template>

  </div>
</template>


<style>

  .evaluation_month_container .el-radio__input.is-checked+.el-radio__label {
    color: #FC8434 !important;
  }
  .evaluation_month_container .el-radio__input.is-checked .el-radio__inner {
    border-color: #FC8434 !important;
    background: #FC8434 !important;
  }

  .evaluation_month_container .table_box {
    box-shadow: none;
  }
  .evaluation_month_container .el-tabs__nav {
    background: #fff;
  }
  .evaluation_month_container .el-tabs__header {
    margin-bottom: 0;
  }
  .evaluation_month_container .el-tabs__content {
    box-shadow: 2px 2px 8px 4px rgba(213,212,212,0.5);
    padding-top: 15px;
    box-sizing: border-box;
    background: #fff;
  }
  .evaluation_month_container .el-tabs--card>.el-tabs__header .el-tabs__nav {
    /* border-bottom: 1px solid #E4E7ED; */
    border-radius: 3px 3px 0 0;
  }
  .evaluation_month_container .el-tabs__item {
    height: 35px;
    line-height: 35px;
    font-size: 12px !important;
    border-bottom: 1px solid #E4E7ED !important;
  }
  .evaluation_month_container .el-tabs__content{
    border-left: 1px solid #E4E7ED;
  }

  .evaluation_month_container .el-tabs__item.is-active {
    color: #FC8434;
    border-bottom: 1px solid #fff !important;
  }
  
</style>
<style scoped>

.select_box{
  padding: 0 0 15px 15px;
}


.month_table_item{
  margin-bottom: 25px;
  position: relative;
}
.month_table .month_table_item:last-child {
  margin-bottom: 0;
}
.addMonth{
  cursor: pointer;
  color: #77A4FF;
  text-align: right;
  padding: 10px 0;
  float: right;
}
.deleteMonth{
  position: absolute;
  right: 10px;
  top: 0;
}
.addProduct {
  cursor: pointer;
  line-height: 25px;
  color: #77A4FF;
}
.tab_box{
  padding-left: 15px;
  margin-bottom: 10px;
}

.table_box .table_title {
  background: #F5F7FA;
  text-align: right;
  height: 30px;
  line-height: 30px;
  color: #77A4FF;
  font-size: 12px;
  padding-right: 20px;
}

.tab_box .btn_tab.isActive {
  background: #77A4FF;
  color: #fff;
}
.tab_box .btn_tab {
  width:70px;
  height:25px;
  line-height: 25px;
  margin-right: 15px;
  color: #77A4FF;
  font-size: 12px;
  cursor: pointer;
  text-align: center;
  border: 1px solid #77A4FF;
  border-radius:15px;
}
.tab_box .btn_tab:hover {
  background: #77A4FF;
  color: #fff;
}

.btn_search {
  padding: 0 20px;
  text-align: center;
  height: 32px;
  font-size: 12px;
  background: #FBA56C;
  line-height: 32px;
}
.search_box {
  padding: 0 15px;
  box-sizing: border-box;
}
</style>

<script>
import adminTable from '@/components/assembly/adminTable';
import eidtTable from '@/components/assembly/eidtTable'
import questionAnalysis from '@/components/page/system_management/evaluateManagement/questionAnalysis'
import {
  createNamespacedHelpers,
  mapState,
} from "vuex";
let {
  // mapState,
  mapGetters,
  mapMutations,
  mapActions
} = createNamespacedHelpers("evaluationMonth");



export default {
  name: 'evaluationMonth',
  data() {
    return {
        activeName: 'class',
        isActiveEcharts: false,
        jwtAuth: {},
        schoolList: [],
        subjectList: [],
      /* ===== 班级 ====== */
        searchFormClass: {
          schoolId: [],
          rptTime: [],
          financialMonth: '',
          rptTimeEnd: '',
          rptTimeStart: '',
        },
        tableHeadClass: {
          border: true,
          data: [
            {
              name: "班级",
              key: "className",
              align: "center",
            },
            {
              name: "校区",
              key: "schoolName",
              align: "center",
            },
            {
              name: "班级人数",
              key: "classNumber",
              align: "center"
            },
            {
              name: "参评人数",
              key: "evaluationNumber",
              align: "center"
            },
            {
              name: "参评率",
              key: "participationRate",
              align: "center",
            },
            {
              name: "班级管理满意度",
              key: "classManagementSatisfaction",
              align: "center"
            },
            {
              name: "班主任老师",
              key: "headmasterTeacher",
              align: "center",
            },
            {
              name: "辅班老师",
              key: "auxiliaryClass",
              align: "center",
            },
          ]
        },
        tableDataClass: [
        ],
        pageClass: {},
      /* ===== 班级 END ====== */

        
      /* ===== 教学 ====== */
        radio: '1',
        subjectList: [
          {
            subjectName: '语文',
            subjectId: '40022',
          },
          {
            subjectName: '数学',
            subjectId: '40023',
          },
          {
            subjectName: '英语',
            subjectId: '40024',
          },
        ],
        searchFormTeach: {
          financialMonth: '',
          schoolId: [],
          subject: '',
        },
        tableHeadTeachClass: {
          data: [
            {
              name: "校区",
              key: "schoolName",
              align: "center",
            },
            {
              name: "班级",
              key: "className",
              align: "center",
            },
            {
              name: "语文",
              key: "chinese",
              align: "center"
            },
            {
              name: "满意度",
              key: "chineseSatisfied",
              align: "center"
            },
            {
              name: "数学",
              key: "math",
              align: "center",
            },
            {
              name: "满意度",
              key: "mathSatisfied",
              align: "center"
            },
            {
              name: "英语",
              key: "english",
              align: "center",
            },
            {
              name: "满意度",
              key: "englishSatisfied",
              align: "center",
            },
          ]
        },
        tableDataTeachClass: [],

        tableHeadTeachTeacher: {
          data: [
            {
              name: "教学科目",
              key: "subject",
              align: "center",
            },
            {
              name: "姓名",
              key: "employeesName",
              align: "center",
            },
            {
              name: "工号",
              key: "workNo",
              align: "center"
            },
            {
              name: "评价数",
              key: "evaluationNumber",
              align: "center"
            },
            {
              name: "得分",
              key: "averageScore",
              align: "center",
            },
          ]
        },
        tableDataTeachTeacher: [],
        pageTeach: {
          pageSize: 10,
          curPage: 1,
          totalRows: 0,
        },
      /* ===== 教学 END ====== */

      /* ===== 校区 ====== */
        searchFormSchool: {
          financialMonth: '',
          schoolId: [],
        },
        tableHeadSchool: {
          data: [
            {
              name: "校区",
              key: "schoolName",
              align: "center",
            },
            {
              name: "校长",
              key: "principal",
              align: "center",
            },
            {
              name: "运营主管",
              key: "operationSupervisor",
              align: "center",
            },
            // {
            //   name: "工号",
            //   key: "workNo",
            //   align: "center"
            // },
            {
              name: "校区学员数",
              key: "schoolNumber",
              align: "center"
            },
            {
              name: "评价人数",
              key: "evaluationNumber",
              align: "center"
            },
            {
              name: "参评率",
              key: "participationRate",
              align: "center",
            },
            {
              name: "运营满意度",
              key: "operationalSatisfaction",
              align: "center"
            },
            {
              name: "整体满意度",
              key: "overallSatisfaction",
              align: "center"
            },
          ]
        },
        tableDataSchool: [],
        pageSchool: {},
      /* ===== 校区 END ====== */

      
    
    }
  },
  created() {
    this.jwtAuth = JSON.parse(sessionStorage.getItem('jwtAuth'));
    this.queryAllSchool();

    if(sessionStorage.getItem('evalutionMonthTabName')) {
      this.activeName = sessionStorage.getItem('evalutionMonthTabName');
    }else{
      this.activeName = 'class';
    }

    

  },
  watch: {
    radio(newVal, oldVal) {
      if(this.radio == 1) {
        this.initClassAnaData();
      }else{
        this.initTeacherAnaData();
      }
    }
  },
  methods: {
    ...mapMutations([
      "updateInfo",
    ]),
    ...mapActions([
      "formGet",
      "post",
      "export",
    ]),

    queryAllSchool(btnId) {
      let accountId
      this.jwtAuth.schoolId == '' ? accountId = '' : accountId = this.jwtAuth.accountId

      // let schoolIds = null
      
      // let arr = this.jwtAuth.schoolId.split(',')
      // console.log(arr);
      // for(let i=0; i<arr.length; i++) {
      //   if(arr[i] == '') {
      //     schoolIds = [];
      //     break;
      //   }else{
      //     schoolIds = this.jwtAuth.schoolId.split(',')
      //   }
      // }

      // console.log(schoolIds)
      
      this.post({
        API: 'queryAllSchool',
        data: {
          accountId: accountId,
          menuId: btnId || this.$route.name,
          schoolIds: this.jwtAuth.schoolId.split(','),
        }
      }).then(res => {
        // if(btnId) {
        //   this.powerSchoolList = res
        //   this.formDataMonth.schoolId = this.powerSchoolList[0].schoolId
        //   if(this.activeName == 'monthly') {
        //     this.changeMonthSchool(this.formDataMonth.schoolId)
        //   }
          
        // }else{
        //   this.schoolList = res
        // }
        this.schoolList = res;
        this.schoolList = this.schoolList.filter(val => {
          return val.schoolId !== '';
        });
        console.log(this.schoolList)
        // this.powerSchoolList = res;
        switch (this.activeName) {
          case 'class':
            this.initClassData();
            this.isActiveEcharts = false;
            break;
          case 'teach':
            this.initClassAnaData();
            this.isActiveEcharts = false;
            break;
          case 'school':
            this.initSchoolData();
            this.isActiveEcharts = false;
            break;
          case 'qsAnalysis':
            // this.initMonthData();
            this.isActiveEcharts = true;
            break;
        
          default:
            break;
        }
      }).catch(err => {
        this.$message.error(err);
      })
    },

    handleClick(tab, event) {
      // console.log(tab, event);
      sessionStorage.setItem('evalutionMonthTabName', tab.name)
      switch (tab.name) {
        case 'class':
          this.initClassData();
          this.isActiveEcharts = false;
          break;
        case 'teach':
          this.initClassAnaData();
          this.isActiveEcharts = false;
          break;
        case 'school':
          this.initSchoolData();
          this.isActiveEcharts = false;
          break;
        case 'qsAnalysis':
          // this.initMonthData();
          this.isActiveEcharts = true;
          break;
      
        default:
          break;
      }
    },


  /* ========================= 班级START =========================== */
    exportClass() {
      let data = {};


      // data.schoolId = this.searchFormClass.schoolId;

      let schoolIdArr = [];
      data.schoolId = this.searchFormClass.schoolId
      console.log(data.schoolId)
      if(!data.schoolId || data.schoolId.length == 0) {
        this.schoolList.forEach(item => {
          schoolIdArr.push(item.schoolId);
        })
        data.schoolId = schoolIdArr;
      }else{
        data.schoolId = this.searchFormClass.schoolId
      }

      if(this.searchFormClass.financialMonth) {
        
        let endTimeArr = this.searchFormClass.financialMonth.split('-')

        if(endTimeArr[1] >= 12) {
          endTimeArr[0] = Number(endTimeArr[0]) + 1
          endTimeArr[1] = 1
        }else{
          endTimeArr[1] = Number(endTimeArr[1]) + 1
        }

        let endTime = endTimeArr.join('-') + '-03 23:59:59';

        data.rptTimeStart = this.searchFormClass.financialMonth + '-28 00:00:00';
        data.rptTimeEnd = endTime;
      }

      console.log(data);
      this.export({
        API: 'exportBmExamplesMonthForClass',
        data: data
      }).then(res => {

      }).catch(err => {
        this.$message.error(err);
      })
    },
    searchClassData(searchFormClass) {
      this.pageClass.curPage = 1;
      this.initClassData(searchFormClass)
    },

    initClassData(searchForm) {
      let searchValue = searchForm || this.searchFormClass || '';
      let data = {}
      Object.assign(data, searchValue);
      data.curPage = this.pageClass.curPage;
      data.pageSize = this.pageClass.pageSize;
      data.accountId = this.jwtAuth.accountId;
      data.menuId = this.$route.name;

      let schoolIdArr = [];
      if(!data.schoolId || data.schoolId.length == 0) {
        this.schoolList.forEach(item => {
          schoolIdArr.push(item.schoolId);
        })
        data.schoolId = schoolIdArr;
      }else{
        data.schoolId = this.searchFormClass.schoolId
      }

      

      
      if(this.searchFormClass.financialMonth) {
        let endTimeArr = this.searchFormClass.financialMonth.split('-')
        if(endTimeArr[1] >= 12) {
          endTimeArr[0] = Number(endTimeArr[0]) + 1
          endTimeArr[1] = 1
        }else{
          endTimeArr[1] = Number(endTimeArr[1]) + 1
        }

        console.log(endTimeArr)
        let endTime = endTimeArr.join('-') + '-03 23:59:59';

        data.rptTimeStart = this.searchFormClass.financialMonth + '-28 00:00:00';
        data.rptTimeEnd = endTime;
      }

      this.post({
        API: 'queryBmExamplesMonthForClass',
        data: data
      }).then(res => {
        this.tableDataClass = res.data;
        this.pageClass = res.page;
      }).catch(err => {
        this.$message.error(err);
      })
    },

    handleSizeChange(val) {
      this.pageClass.pageSize = val;
      this.initClassData();
    },
    handleCurrentChange(val) {
      // console.log(`当前页: ${val}`);
      this.pageClass.curPage = val;
      this.initClassData();
    },

  /* ========================= 班级END =========================== */
  
  /* ========================= 教学START =========================== */
    exportTeach() {
      let data = {};

      if(this.searchFormTeach.financialMonth) {
        let endTimeArr = this.searchFormTeach.financialMonth.split('-')
        if(endTimeArr[1] >= 12) {
          endTimeArr[0] = Number(endTimeArr[0]) + 1
          endTimeArr[1] = 1
        }else{
          endTimeArr[1] = Number(endTimeArr[1]) + 1
        }

        let endTime = endTimeArr.join('-') + '-03 23:59:59';

        data.rptTimeStart = this.searchFormTeach.financialMonth + '-28 00:00:00';
        data.rptTimeEnd = endTime;
      }

      console.log(data);

      let exportUrl = '';

      let schoolIdArr = [];
      data.schoolId = this.searchFormTeach.schoolId
      // console.log(data.schoolId)
      if(!data.schoolId || data.schoolId.length == 0) {
        this.schoolList.forEach(item => {
          schoolIdArr.push(item.schoolId);
        })
        data.schoolId = schoolIdArr;
      }else{
        data.schoolId = this.searchFormTeach.schoolId
      }

      if(this.radio == 1) {
        // data.schoolId = this.searchFormTeach.schoolId;
        exportUrl = 'exportBmExamplesMonthForTeacher'
      }else{
        data.subject = this.searchFormTeach.subject
        exportUrl = 'exportBmExamplesMonthForTeacherContrast'
      }

      this.export({
        API: exportUrl,
        data: data
      }).then(res => {

      }).catch(err => {
        this.$message.error(err);
      })
    },
    changeSchool(e) {
      this.initClassAnaData()
    },
    changeSubject(e) {
      this.initTeacherAnaData()
    },
    searchTeachData(searchFormTeach) {
      this.pageTeach.curPage = 1;
      if(this.radio == 1) {
        this.initClassAnaData(searchFormTeach)
      }else{
        this.initTeacherAnaData(searchFormTeach)
      }
    },

    // 班级分析
    initClassAnaData(searchForm) {
      let searchValue = searchForm || this.searchFormTeach || '';
      let data = {}
      Object.assign(data, searchValue);
      data.curPage = this.pageTeach.curPage;
      data.pageSize = this.pageTeach.pageSize;
      data.accountId = this.jwtAuth.accountId;
      data.menuId = this.$route.name;

      let schoolIdArr = [];
      if(!data.schoolId || data.schoolId.length == 0) {
        this.schoolList.forEach(item => {
          schoolIdArr.push(item.schoolId);
        })
        data.schoolId = schoolIdArr;
      }else{
        data.schoolId = this.searchFormTeach.schoolId
      }

      
      
      if(this.searchFormTeach.financialMonth) {
        let endTimeArr = this.searchFormTeach.financialMonth.split('-')
        if(endTimeArr[1] >= 12) {
          endTimeArr[0] = Number(endTimeArr[0]) + 1
          endTimeArr[1] = 1
        }else{
          endTimeArr[1] = Number(endTimeArr[1]) + 1
        }

        let endTime = endTimeArr.join('-') + '-03 23:59:59';

        data.rptTimeStart = this.searchFormTeach.financialMonth + '-28 00:00:00';
        data.rptTimeEnd = endTime;
      }
      this.post({
        API: 'queryBmExamplesMonthForTeacher',
        data: data
      }).then(res => {
        this.tableDataTeachClass = res.data;
        this.pageTeach = res.page
      }).catch(err => {
        this.$message.error(err);
      })
    },

    // 老师对比
    initTeacherAnaData(searchForm) {
      let searchValue = searchForm || this.searchFormTeach || '';
      let data = {}
      Object.assign(data, searchValue);
      data.curPage = this.pageTeach.curPage;
      data.pageSize = this.pageTeach.pageSize;
      data.accountId = this.jwtAuth.accountId;
      data.menuId = this.$route.name;

      let schoolIdArr = [];
      if(!data.schoolId || data.schoolId.length == 0) {
        this.schoolList.forEach(item => {
          schoolIdArr.push(item.schoolId);
        })
        data.schoolId = schoolIdArr;
      }else{
        data.schoolId = this.searchFormTeach.schoolId
      }

      
      if(this.searchFormTeach.financialMonth) {
        let endTimeArr = this.searchFormTeach.financialMonth.split('-')
        if(endTimeArr[1] >= 12) {
          endTimeArr[0] = Number(endTimeArr[0]) + 1
          endTimeArr[1] = 1
        }else{
          endTimeArr[1] = Number(endTimeArr[1]) + 1
        }

        let endTime = endTimeArr.join('-') + '-03 23:59:59';

        data.rptTimeStart = this.searchFormTeach.financialMonth + '-28 00:00:00';
        data.rptTimeEnd = endTime;
      }
      this.post({
        API: 'queryBmExamplesMonthForTeacherContrast',
        data: data
      }).then(res => {
        this.tableDataTeachTeacher = res.data;
        this.pageTeach = res.page
      }).catch(err => {
        this.$message.error(err);
      })
    },
    
    handleSizeChangeYear(val) {
      this.pageTeach.pageSize = val;
      if(this.radio == 1) {
        this.initClassAnaData()
      }else{
        this.initTeacherAnaData()
      }
    },
    handleCurrentChangeYear(val) {
      this.pageTeach.curPage = val;
      if(this.radio == 1) {
        this.initClassAnaData()
      }else{
        this.initTeacherAnaData()
      }
    },

  /* ========================= 教学END =========================== */


  /* ========================= 校区START =========================== */
    exportSchool() {
      let data = {};

      let schoolIdArr = [];
      data.schoolId = this.searchFormSchool.schoolId
      console.log(data.schoolId)
      if(!data.schoolId || data.schoolId.length == 0) {
        this.schoolList.forEach(item => {
          schoolIdArr.push(item.schoolId);
        })
        data.schoolId = schoolIdArr;
      }else{
        data.schoolId = this.searchFormSchool.schoolId
      }

      if(this.searchFormSchool.financialMonth) {
        let endTimeArr = this.searchFormSchool.financialMonth.split('-')
        if(endTimeArr[1] >= 12) {
          endTimeArr[0] = Number(endTimeArr[0]) + 1
          endTimeArr[1] = 1
        }else{
          endTimeArr[1] = Number(endTimeArr[1]) + 1
        }

        let endTime = endTimeArr.join('-') + '-03 23:59:59';

        data.rptTimeStart = this.searchFormSchool.financialMonth + '-28 00:00:00';
        data.rptTimeEnd = endTime;
      }

      this.export({
        API: 'exportBmExamplesMonthForSchool',
        data: data
      }).then(res => {

      }).catch(err => {
        this.$message.error(err);
      })
    },

    searchSchoolData(searchFormMonth) {
      this.pageSchool.curPage = 1;
      this.initSchoolData(searchFormMonth)
    },

    initSchoolData(searchForm) {
      let searchValue = searchForm || this.searchFormSchool || '';
      let data = {}
      Object.assign(data, searchValue);
      data.curPage = this.pageSchool.curPage;
      data.pageSize = this.pageSchool.pageSize;
      data.accountId = this.jwtAuth.accountId;
      data.menuId = this.$route.name;

      let schoolIdArr = [];
      if(!data.schoolId || data.schoolId.length == 0) {
        this.schoolList.forEach(item => {
          schoolIdArr.push(item.schoolId);
        })
        data.schoolId = schoolIdArr;
      }else{
        data.schoolId = this.searchFormSchool.schoolId
      }

      if(this.searchFormSchool.financialMonth) {
        let endTimeArr = this.searchFormSchool.financialMonth.split('-')
        if(endTimeArr[1] >= 12) {
          endTimeArr[0] = Number(endTimeArr[0]) + 1
          endTimeArr[1] = 1
        }else{
          endTimeArr[1] = Number(endTimeArr[1]) + 1
        }

        let endTime = endTimeArr.join('-') + '-03 23:59:59';

        data.rptTimeStart = this.searchFormSchool.financialMonth + '-28 00:00:00';
        data.rptTimeEnd = endTime;
      }

      this.post({
        API: 'queryBmExamplesMonthForSchool',
        data: data
      }).then(res => {
        this.tableDataSchool = res.data;
        this.pageSchool = res.page
      }).catch(err => {
        this.$message.error(err);
      })
    },
    
    
    handleSizeChangeMonth(val) {
      this.pageSchool.pageSize = val;
      this.initSchoolData();
    },
    handleCurrentChangeMonth(val) {
      this.pageSchool.curPage = val;
      this.initSchoolData();
    },
  /* ========================= 校区END =========================== */


  },
  computed: {
    ...mapState([
      "selectProductId",
    ]),

  },
  components: {
    adminTable,
    eidtTable,
    questionAnalysis,
  },
}

</script>